<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java"  pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="spring" uri="/WEB-INF/lib/spring.tld"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%@ taglib prefix="z" uri="/WEB-INF/lib/zerdoor.tld"%>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><spring:message code='works_list.title.msg' /></title>
    <link href="${path}/style/acg/css/style.css" rel="stylesheet" type="text/css" />
    <script src="${path}/js/jquery.min.js" type="text/javascript"></script>
    <link href="${path}/plugins/page/kkpager.css" rel="stylesheet">
    <script src="${path}/plugins/page/kkpager.js" type="text/javascript"></script>


    <script type="text/javascript">

        $(function(){

            f_init();

        });


        //初始化参数
        function f_init(){

            f_findPajectType("1",1);

            //排序
            f_aClick(".listhead a","#orderBy");

            f_aClick(".receiver_level a","#receiver_level");
            f_aClick(".price a","#price");

            $(".morec").click(function(){
                if($(this).html()=="<spring:message code='task_list.msg.more'/>&gt;&gt;")
                {
                    var _h=$("#sortbig").find("dd").height();
                    $("#sortbig").css({"height":_h+"px"});
                    $(this).html("<spring:message code='task_list.msg.collapse'/>");
                }
                else
                {
                    $("#sortbig").css({"height":"24px"});
                    $(this).html("<spring:message code='task_list.msg.more'/>&gt;&gt;");
                }
            });

            initBeanInfo(1,12,decodeURI("${keyword}"));


            $("#likeQuery").click(function(){
                initBeanInfo(1,10);
            });
        }

        /**a点击事件 传入选择器*/
        function f_aClick(selID,inputID){



            $(selID).click(function() {
                $(selID).removeClass("on");

                $(this).addClass("on");

                if(inputID != null && inputID != undefined){

                    $(inputID).val($(this).attr("value"));
                }
                initBeanInfo(1,10);

            });

        }


        /**查询项目分类*/
        function f_findPajectType(parent,level){


            //如果等于空就表示选择的为全部
            if(parent == ""){
                $("#sortsmall").hide();
                $("#sortsmall").find(".twom").html("");
                //给隐藏表单赋空值
                $("#first_class").val("");
                $("#second_class").val("");
                initBeanInfo(1,10);
                return;
            }

            //如果值相等，表示点击相同的标签，不做操作
            if($("#first_class").val() == parent ){

                return;
            }else{
                //不相等则清空二级表单
                $("#second_class").val("");
            }

            $.post("${path}/taskList/findTaskTypeByParent.html", { parent: parent},
                    function(data, textStatus){

                        if(level == 1){

                            var html = "<a href='javascript:;' value='' class='on'><spring:message code='task_list.where.all'/></a>";


                            for(i in data){

                                var type = data[i];
                                html += "<a value='"+type.id+"' href='javascript:;'>"+type.name+"</a>";

                            }

                            $(".first_class").html(html);

                            //绑定事件
                            $("#sortbig a").click(function(){

                                //查询二级分类
                                f_findPajectType($(this).attr("value"),2);

                                $(this).addClass("on").siblings().removeClass("on");

                                $("#first_class").val($(this).attr("value"));
                            });

                        }else{

                            var html = "<a href='javascript:;' value='' class='on'><spring:message code='task_list.where.all'/></a>";

                            for(i in data){

                                var type = data[i];

                                html += "<a href='javascript:;' value='"+type.id+"'>"+type.name+"</a>";

                            }
                            $("#sortsmall").show();
                            $("#sortsmall").find(".twom").html(html);

                            initBeanInfo(1,10);

                            //绑定事件
                            $("#sortsmall a").click(function(){
                                $(this).addClass("on").siblings().removeClass("on");

                                $("#second_class").val($(this).attr("value"));

                                initBeanInfo(1,10);

                            });

                        }
                    });
        }


        var pageSize = 12;
        /**查询任务信息*/
        function initBeanInfo(page, rows,keyword) {
            /**查询任务信息*/
            pageSize = rows;


            /***设置查询数据*/
            var first_class = $("#first_class").val();//一级分类
            var second_class = $("#second_class").val();//二级分类
            var artist_level = $("#receiver_level").val();//艺术家等级
            var price = $("#price").val();//售价区间
            var name = $("#name").val();//标题

            if(keyword != undefined){
                name = keyword;
                $("#name").val(name);
            }

            var orderBy = $("#orderBy").val();//排序

            var param = {rows:rows, page:page, first_class:first_class,second_class:second_class,artist_level:artist_level,
                price:price,name:name,orderBy:orderBy
            };



            $.ajax({
                type: "POST",
                url: "${path}/productionList/findProductionList.html",
                data: param,
                dataType: "json",
                success: function(data){
//                    console.log(data);

                    var html = "";
                    for(var i in data.list){

                        var bean = data.list[i];

                        html += "<div class=\"list_item2\">";
                        html += "<div class=\"litop\"></div>";
                        html += "<div class=\"limain clearfix\">";
                        html += "<div class=\"liimg\"><a href=\"${path}/artistPersonalHome/browseProduction.html?production_id="+bean.works_id+"\"><img src='${path}/"+bean.cover+"' title='"+bean.name+"' alt='"+bean.name+"' width=\"292\" height=\"180\" /></a></div>";
                        html += "<div class=\"licon\">";
                        html += "<h2><a href=\"${path}/artistPersonalHome/browseProduction.html?production_id="+bean.works_id+"\">"+bean.name+"</a></h2>";
                        html += "<div class=\"price\"><span class=\"authour\">by:<em>"+bean.nickname+"</em></span>￥"+bean.price+"</div>";
                        html += "</div>";
                        html += "<div class=\"clr\"></div>";
                        html += "</div>";
                        html += "<div class=\"lifoot\"></div>";
                        html += "</div>";


                    }


                    $("#dataDiv").html(html);

                    var pager = data;
                    //分页
                    createPage(pager.pageNum, pager.pages, pager.total);

                }
            });
        }


        //分页方法
        //currentPage 当前页
        //rows 每页条数
        //total 总数
        function createPage(currentPage, totalPage, totalCount) {
            var totalPage = totalPage;
            var totalRecords = totalCount;
            var pageNo = currentPage;
            if (!pageNo) {
                pageNo = 1;
            }
            //生成分页
            //有些参数是可选的，比如lang，若不传有默认值
            kkpager.generPageHtml({
                pno: pageNo,
                //总页码
                total: totalPage,
                //总数据条数
                totalRecords: totalRecords,
                //链接前部
                hrefFormer: 'index',
                //链接尾部
                hrefLatter: '',
                //是否显示总页数
                isShowTotalPage: true,
                //是否显示总记录数
                isShowTotalRecords: true,
                //是否显示页码跳转输入框
                isGoPage: true,
                //getLink: function (n) {
                //    return this.hrefFormer + this.hrefLatter + "?pno=" + n;
                //}
                //,
                mode : 'click',//默认值是link，可选link或者click
                click : function(n){
                    //this.selectpage(n);
                    initBeanInfo(n, pageSize);
                    return false;
                },
                lang				: {
                    firstPageText			: '<spring:message code="firstPageText"/>',
                    firstPageTipText		: '<spring:message code="firstPageTipText"/>',
                    lastPageText			: '<spring:message code="lastPageText"/>',
                    lastPageTipText			: '<spring:message code="lastPageTipText"/>',
                    prePageText				: '<spring:message code="prePageText"/>',
                    prePageTipText			: '<spring:message code="prePageTipText"/>',
                    nextPageText			: '<spring:message code="nextPageText"/>',
                    nextPageTipText			: '<spring:message code="nextPageTipText"/>',
                    totalPageBeforeText		: '<spring:message code="totalPageBeforeText"/>',
                    totalPageAfterText		: '<spring:message code="totalPageAfterText"/>',
                    totalRecordsAfterText	: '<spring:message code="totalRecordsAfterText"/>',
                    gopageBeforeText		: '<spring:message code="gopageBeforeText"/>',
                    gopageButtonOkText		: '<spring:message code="gopageButtonOkText"/>',
                    gopageAfterText			: '<spring:message code="gopageAfterText"/>',
                    buttonTipBeforeText		: '<spring:message code="buttonTipBeforeText"/>',
                    buttonTipAfterText		: '<spring:message code="buttonTipAfterText"/>'
                }
            },true);
        }
    </script>

</head>

<body>
<div class="header">
    <jsp:include page="../public/header.jsp">
        <jsp:param    name="home"    value="dddd"    />
    </jsp:include>
</div>

<div id="container">
    <div class="wrapper">
        <div class="sortbox">
            <ul>
                <li>
                    <dl id="sortbig" class="clearfix">
                        <dt><spring:message code="works_list.msg.work_classification"/>：</dt>
                        <dd class="first_class">

                        </dd>
                    </dl>
                    <div class="morec"><spring:message code='task_list.msg.more'/>>></div>
                    <dl class="clearfix" id="sortsmall" style="display:none"><!--若需要隐藏该层display:none-->
                        <dt>&nbsp;&nbsp;</dt>
                        <dd>
                            <div class="twom">

                            </div>
                        </dd>
                    </dl>
                    <input type="hidden" id="first_class"><input type="hidden" id="second_class">
                </li>
                <li>
                    <dl class="clearfix receiver_level">
                        <dt><spring:message code="works_list.msg.authorRating"/>：</dt>
                        <dd>
                            <a value="" class="on"><spring:message code="works_list.msg.all"/></a>
                            <c:forEach items="${initData.artistGrade}" var="artistGrade">
                                <a value="${artistGrade.id}">${artistGrade.name}</a>
                            </c:forEach>


                        </dd>
                    </dl>
                    <input type="hidden" id="receiver_level">
                    </dl>
                </li>
                <li>
                    <dl class="clearfix price">
                        <dt><spring:message code="works_list.msg.priceRange"/>：</dt>
                        <dd>
                            <a  value="" class="on"><spring:message code='task_list.where.all'/></a>
                            <a  value="0-1000">1000&nbsp;<spring:message code='task_list.where.theFollowing'/></a>
                            <a  value="1000-5000">1000&nbsp;<spring:message code='task_list.where.to'/>&nbsp;5000</a>
                            <a  value="5000-10000">5000&nbsp;<spring:message code='task_list.where.to'/>&nbsp;10000</a>
                            <a  value="10000-50000">10000&nbsp;<spring:message code='task_list.where.to'/>&nbsp;50000</a>
                            <a  value="50000-999999999">50000&nbsp;<spring:message code='task_list.where.orMore'/></a>
                        </dd>
                        <input type="hidden" id="price">
                    </dl>
                </li>
            </ul>
        </div>
        <div class="listbox">
            <div class="listhead">
                <ul>
                    <li><a value="publish_time desc" class="on"><spring:message code="works_list.order.published"/></a></li>
                    <li><a value="price"><spring:message code="works_list.order.priceRange"/></a></li>
                    <li><a value="click_rate desc"><spring:message code="works_list.order.heatWorks"/></a></li>
                    <li class="research">
                        <input class="txt" type="text" autocomplete="off" id="name" name="name"  />
                        <input id="orderBy" type="hidden" value="publish_time desc">
                        <input type="button" id="likeQuery" value="<spring:message code='works_list.button.search'/>" class="btn" />
                    </li>
                </ul>
            </div>
            <div class="reelscontainer">
                <div class="listview clearfix" id="dataDiv">

                    </div>

                    <%--<div class="list_item2 nomr">--%>
                        <%--<div class="litop"></div>--%>
                        <%--<div class="limain clearfix">--%>
                            <%--<div class="liimg"><a href=""><img src="upload/7.jpg" width="292" height="180" /></a></div>--%>
                            <%--<div class="licon">--%>
                                <%--<h2><a href="">作品标题作品标题空空如也</a></h2>--%>
                                <%--<div class="price"><span class="authour">by:<em>王群书</em></span>￥6000</div>--%>
                            <%--</div>--%>
                        <%--</div>--%>
                        <%--<div class="lifoot"></div>--%>
                    <%--</div>--%>
                    <div class="clr"></div>
                </div>
                <div class="pagebox">
                    <div id="kkpager" style="text-align: center"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="footer">
    <!--content-->
    <jsp:include page="../public/footer.jsp"></jsp:include>
</div>

<%--<script type="text/javascript" src="${path}/style/acg/js/common.js"></script>--%>
</body>
</html>
